﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Curry.Forum.Query.Service.DTOS
{
    public class ArticleInfo
    {
        /// <summary>
        /// 文章ID
        /// </summary>
        public int Id { get; set; }
        /// <summary>
        /// 文章标题
        /// </summary>
        public string Title { get; set; }
        /// <summary>
        /// 文章内容
        /// </summary>
        public string ArticleContent { get; set; }
        /// <summary>
        /// 作者
        /// </summary>
        public string Author { get; set; }
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime Createdon { get; set; }

        private DateTime lastUpdateTime;
        /// <summary>
        /// 上次更新时间
        /// </summary>
        public string LastUpdateTime
        {
            get { return lastUpdateTime.ToString("yyyy-MM-dd hh:mm:ss"); }
            set { lastUpdateTime = Convert.ToDateTime(value); }
        }
        /// <summary>
        /// 作者Id
        /// </summary>
        public int AuthorId { get; set; }
        /// <summary>
        /// 类别
        /// </summary>
        public int Type { get; set; }
        /// <summary>
        /// 标签
        /// </summary>
        public string Tag { get; set; }

        public const string GetCountSql = @"select count(Id) TotalNum from Article where 1=1";

        public const string GetSql = @"select * from Article where 1=1";

        public const string GetPagingSql = @"SELECT *
FROM (
	SELECT ROW_NUMBER() OVER (ORDER BY id) AS rownumber, *
	FROM Article
) a1
WHERE rownumber >= {0}
	AND rownumber <= {1}";
    }
}
